package com.example.liverock.myshape;

import android.app.Activity;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends Activity {

    EditText circumperence;
    EditText area;
    EditText other;

    Button circle;
    Button rectangle;

    Shape shape;
    Poly poly;

    int type = 0;

    ShapeFactory shapeFactory = new ShapeFactory();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        SharedPreferences setting = getSharedPreferences("lalal", MODE_PRIVATE);
       // setting.edit().put


        circumperence = (EditText)findViewById(R.id.circumference);
        area = (EditText)findViewById(R.id.area);
        other = (EditText)findViewById(R.id.other);

        circle = (Button)findViewById(R.id.circle);
        rectangle = (Button)findViewById(R.id.rectangle);

        circle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String str = "";
                test(str);


            }
        });

        rectangle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });


    }
    void test(String str)
    {
        if (str == "")
        {
            throw new IllegalArgumentException("String can not be 为无 ");
        }
        else
        {
            Toast.makeText(this, str, Toast.LENGTH_SHORT).show();
        }
    }
    private void Informaiton()
    {
        shape = shapeFactory.CreateBaseShpae(type);
        poly = shapeFactory.CreateInterfaceShpae(type);
        circumperence.setText(shape.Curcumference());
        area.setText(shape.Area());
        other.setText(poly.SideNumber());
    }
}






